<template>
  <div class="like_list">
    <div class="like_ttle">
      <div class="head">
        <div><i></i> <b>根据您的偏好猜您可能喜欢</b></div>
      </div>
    </div>
    <div class="likes">
      <ul>
        <router-link
          :to="{ name: 'detail2', query: { data: 1, id: item.product_id } }"
          tag="li"
          v-for="item in likeBooks"
          :key="item.product_id"
        >
          <img :src="item.image_url" alt="" />
          <p>{{ item.name }}</p>
          <div class="xin">
            <span
              :class="value.type ? 'con' : ''"
              v-for="(value, index) in item.productTags"
              :key="index"
              >{{ value.name }}</span
            >
          </div>
          <div class="prec">
            <i>￥</i><span>{{ (item.price) }}</span>
          </div>
          <div class="pinjia">{{ item.review_count }}人评价</div>
        </router-link>
      </ul>
    </div>
  </div>
</template>

<script>
import { getHomepageBall } from "../api/home";
import { getLike } from "../api/likes";
export default {
  data() {
    return {
      booksData: [],
      userLogin: false,
      likeBooks:[]
    };
  },
  methods: {
    getHomepageBallFun() {
      getHomepageBall().then((data) => {
        this.booksData = data.booksData;
        // console.log(this.booksData);
      });
    },
    getLikeFun() {
      getLike().then((data) => {
        this.likeBooks = data.data
        // console.log(this.likeBooks);
      });
    },
  },
  created() {
    this.getHomepageBallFun();
    this. getLikeFun();
  },
};
</script>

<style lang="scss" scoped>
.like_list {
  .like_ttle {
    width: 100%;
    border-top: 2px solid #eee;
    .head {
      height: 51px;
      font-size: 15px;
      display: flex;
      align-items: center;
      justify-content: center;
      background-color: #f2f2f2;
      position: relative;
      div {
        background-color: #f2f2f2;
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 1;
        padding: 0 12px;
      }
      &::after {
        content: "";
        position: absolute;
        left: 7%;
        font-size: 0;
        line-height: 0;
        background-color: #dadada;
        height: 1px;
        width: 85%;
      }
      i {
        z-index: 1;
        display: block;
        width: 18px;
        height: 18px;
        background: url("../../public/images/img/下载\ \(1\).png") center
          no-repeat;
        background-size: cover;
        margin-right: 5px;
      }
      b {
        font-weight: normal;
        z-index: 1;
        font-size: 13px;
        color: #323232;
      }
    }
  }
  .likes {
    width: 100%;
    background-color: #f2f2f2;
    ul {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      li {
        width: 49.5%;
        background-color: #fff;
        padding-bottom: 8.7px;
        margin-bottom: 4px;
        img {
          width: 100%;
          display: block;
        }
        p {
          padding: 5px 5px 0;
          color: #232323;
          font-size: 14px;
          margin-bottom: 2px;
          text-overflow: ellipsis;
          overflow: hidden;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
        }
        .xin {
          color: #f2303c;
          font-size: 12px;
          padding-left: 5px;
          span {
            border: 1px solid #f2303c;
            border-radius: 2px;
            margin-right: 4px;
          }
          span.con {
            background-color: #f2303c;
            color: #fff;
          }
        }
        .prec {
          margin-top: 5px;
          padding-left: 5px;
          color: #e53e30;
          span {
            font-size: 16px;
          }
          em {
            font-size: 14px;
          }
        }
        .pinjia {
          margin-top: 5px;
          font-size: 12px;
          color: #b4b4b4;
          padding-left: 5px;
        }
      }
    }
  }
}
</style>